/*********************************************************
          File Name:emplace.cpp
          Author: Abby Cin
          Mail: abbytsing@gmail.com
          Created Time: Mon 14 Sep 2015 07:29:32 PM CST
**********************************************************/

#include <iostream>
#include <list>
#include <vector>
#include <string>

using std::string;
using std::list;
using std::vector;
using std::cout;
using std::endl;

class T {
        private:
                string s;
                int a;
                bool ok;
        public:
                T(string str, int n, bool w) :s(str), a(n), ok(w) {}
                T(string str) :T(str, 0, true) {}
                string &get() { return s; }
};

int main()
{
        list<T> ls{T("start")};

        //ls.push_back("test", 1, true); // wrong
        ls.emplace_back("test", 1, false);        // call first constructor
        ls.emplace(ls.end(), "test");           // call second constructor
        ls.push_back(T("test", 1, true));       // same as above, 

        for(auto &x: ls)
                cout << x.get() << endl;
}
